package demo2;

/**
 * Created with Intellij IDEA.
 * Description:
 * User: 33013
 * Date: 2023-09-16
 * Time: 22:47
 */
public class Test5 {
    public static volatile int count = 0;
    public static void main(String[] args) throws InterruptedException {
        Thread t1 = new Thread(() -> {
            while(count == 0){
                ;
            }
        });
        Thread t2 = new Thread(() -> {
            try {
                Thread.currentThread().sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            count = 1;
        });
        t1.start();
        t2.start();
        t1.join();
    }
}
